/**
 * Bridge Test - North Theme v1.0.0
 * @author    : Object.NET, Inc. http://bridge.net/
 * @copyright : Copyright 2008-2017 Object.NET, Inc. (http://object.net) All Rights Reserved.
 */
(function(funcName, baseObj) {
    funcName = funcName || "qunitReady";
    baseObj = baseObj || window;
    var readyList = [];
    var readyFired = false;
    var readyEventHandlersInstalled = false;
    function ready() {
        if (!readyFired) {
            readyFired = true;
            for (var i = 0; i < readyList.length; i++) {
                readyList[i].fn.call(window, readyList[i].ctx);
            }
            readyList = [];
        }
    }
    function readyStateChange() {
        if (document.readyState === "complete") {
            ready();
        }
    }
    baseObj[funcName] = function(callback, context) {
        if (typeof callback !== "function") {
            throw new TypeError("callback for qunitReady(fn) must be a function");
        }
        if (readyFired) {
            setTimeout(function() {
                callback(context);
            }, 1);
            return;
        } else {
            readyList.push({
                fn: callback,
                ctx: context
            });
        }
        if (document.readyState === "complete") {
            setTimeout(ready, 1);
        } else if (!readyEventHandlersInstalled) {
            if (document.addEventListener) {
                document.addEventListener("DOMContentLoaded", ready, false);
                window.addEventListener("load", ready, false);
            } else {
                document.attachEvent("onreadystatechange", readyStateChange);
                window.attachEvent("onload", ready);
            }
            readyEventHandlersInstalled = true;
        }
    };
})("qunitReady", window);

window.qunitReady(function() {
    QUnit.begin(function(details) {
        var bridgeVersion = Bridge && Bridge.SystemAssembly && Bridge.SystemAssembly.version ? Bridge.SystemAssembly.version : null;
        var qunit = document.getElementById("qunit");
        qunit.removeChild(document.getElementById("qunit-header"));
        qunit.removeChild(document.getElementById("qunit-banner"));
        var header = document.createElement("div");
        header.id = "qunit-header";
        header.innerHTML = "<div class='header-left'>" + "<a class='logo' href='http://testing.bridge.net'>" + "<svg xmlns='http://www.w3.org/2000/svg' width='175' height='19.5' viewBox='0 0 175 19.5'><path d='M51.6 15.6h-5V4.1h4.5c.8 0 1.5.1 2 .3.6.2 1 .4 1.3.8.5.6.8 1.3.8 2 0 .9-.3 1.6-.9 2-.2.2-.3.2-.4.3-.1 0-.2.1-.4.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4-.6-.4-1s.1-.8.4-1c.3-.3.6-.4 1-.4s.8.1 1 .4c.3.3.4.6.4 1s-.1.7-.4 1c-.3.3-.6.4-1 .4-.3 0-.7-.1-1-.4zM144.7 4.1h2.6v11.5h-2.6l-5.5-7.2v7.2h-2.6V4.1h2.4l5.7 7.4V4.1zM161.1 4.1v2.3h-5.7v2.4h5.2V11h-5.2v2.4h5.9v2.3h-8.5V4.1h8.3zM171.7 6.3v9.3h-2.6V6.3h-3.3V4.1h9.1v2.2h-3.2zM25.8 19.5h3V13l-3-3.4v9.9zm5.7-3.5v3.4h3l-3-3.4zM20 19.5h3v-13l-3-3.4v16.4zm-20 0h4.1L14.3 7.9v11.5h3V0L0 19.5z'/></svg>" + "</a>" + "<span class='header-text'>Test Library</span>" + "</div>" + "<div class='header-right'>" + "<span id='bridge-version'>Bridge.NET " + bridgeVersion + "</span>" + "<span id='result-container'></span>" + "<span id='qunit-banner'></span>" + "</div>";
        qunit.insertBefore(header, document.getElementById("qunit-testrunner-toolbar"));
        var userAgent = document.getElementById("qunit-userAgent");
        if (userAgent) {
            userAgent.innerHTML = "";
            userAgent.appendChild(document.createTextNode(navigator.userAgent));
        }
        userAgent.parentNode.insertBefore(userAgent, document.getElementById("qunit-testrunner-toolbar"));
        var qunitUrlConfig = document.getElementsByClassName("qunit-url-config");
        var labels = Array.prototype.slice.call(qunitUrlConfig[0].childNodes);
        labels.forEach(function(label) {
            var switchEl = document.createElement("div");
            switchEl.className = "switch";
            label.appendChild(switchEl);
        });
        var testResultsProgressDiv = document.getElementById("qunit-testresult");
        var loader = document.createElement("div");
        loader.id = "loader";
        loader.innerHTML = "<div class='loader-container'>" + "<div class='loader'>" + "<span class='dot dot_1'></span>" + "<span class='dot dot_2'></span>" + "<span class='dot dot_3'></span>" + "<span class='dot dot_4'></span>" + "</div>" + "</div>";
        testResultsProgressDiv.parentNode.insertBefore(loader, testResultsProgressDiv.nextSibling);
    });
    QUnit.done(function(details) {
        var qunit = document.getElementById("qunit");
        qunit.removeChild(document.getElementById("qunit-testresult"));
        var results = document.createElement("div");
        results.className = "qunit-test-results";
        qunit.insertBefore(results, document.getElementById("qunit-tests"));
        results.innerHTML = "<div class='results'>" + "<div class='result'><span class='total'><i class='ti-pulse'></i>" + details.total + "</span>assertions</div>" + "<div class='result'><span class='passed'><i class='ti-check'></i>" + details.passed + "</span>passed</div>" + "<div class='result'><span class='failed'><i class='ti-close'></i>" + details.failed + "</span>failed</div>" + "</div>" + "<div class='qunit-test-runtime'>Tests completed in " + details.runtime + " miliseconds</div>";
        var resultLabel = details.failed ? "Some Tests Failed" : "All Tests Passed";
        document.getElementById("result-container").innerHTML = "<span class='result-label'>" + resultLabel + "</span>";
        qunit.removeChild(document.getElementById("loader"));
        document.getElementById("qunit-tests").style.visibility = "visible";
        document.getElementById("qunit-tests").style.display = "block";
        var footer = document.createElement("footer");
        var footerHTML = "<div>&copy; 2008 - " + new Date().getFullYear() + " <a href='http://object.net'>Object.NET, Inc.</a> All Rights Reserved</div>";
        footer.innerHTML = footerHTML;
        document.getElementById("qunit").appendChild(footer);
    });
});